#ifndef BEAR_H
#define BEAR_H

#include <QList>
#include <QHash>
#include <QString>
#include <QVariant>
#include <QListIterator>
#include <QMetaType>

#include "BBObject.h"

class BlackBear;
class SqlManager;

class Bear
{
public:
	Bear()
	{
		//DOES NOTHING
	}
	virtual ~Bear()
	{
		//DOES NOTHING
	}

	void addObject( BBObject* newObject );

	QVariant getAttributeValue( QString& className, QString& attributeName )
	{
		return m_objects[className]->getAttributePrimitiveValue( attributeName );
	}

	void setAttributeValue( QString& className, QString& attributeName, QVariant value )
	{
		m_objects[className]->setAttributePrimitiveValue( attributeName, value);
	}

	QHash<QString, BBObject*> getObjects()
	{
		return m_objects;
	}

	BBObject* getObject( QString objectName )
	{
		return m_objects[objectName];
	}

	QString getAttributeType( QString& className, QString& attributeType )
	{
		return m_objects[className]->getAttributeType( attributeType );
	}

	void setAttributeType( QString& className, QString& attributeType, QString type )
	{
		m_objects[className]->setAttributePrimitiveValue( attributeType, type );
	}

	QList<QString> getInitializationOrder()
	{
		return m_initializationOrder;
	}

	QList<BBObject*> getObjectsInitializationOrder();

	QList<BBObject*> getObjectsInitializationOrderReversed();

	BBObject* getFirstObject()
	{
		return m_objects[m_initializationOrder.first()];
	}

private:
	QHash<QString, BBObject*> m_objects;
	QList<QString> m_initializationOrder;
};

//Permit QVariant manipulate bears
Q_DECLARE_METATYPE( Bear );

#endif //BEAR_H
